package com.common.test;

	/**
		@author 王嘉犇
		@name 前台登录
		@type 动作类
	 */

public class FrontLogin extends OperationBase {
	
    public FrontLogin(UITestBase tb){
        super(tb);
    }
    
    public void frontlogin(String username, String password) throws Exception{
    	log.info("===start frontlogin Operation===");
        FrontLoginPage flp = new FrontLoginPage(tb);
        switchToDefaultContent();
        waitForElementExist(flp.homepageLnk);
        flp.usernameLnk.setfindName("linkText");
        flp.usernameLnk.setfindValue(username);
        if(!isPresent(flp.usernameLnk)){
            if(isPresent(flp.safelogoutLnk)){
            	flp.safelogoutLnk.click();
            }
            waitForElementExist(flp.loginLnk);
            flp.loginLnk.click();
            waitForElementExist(flp.accountinput);
            flp.accountinput.clear();
            flp.accountinput.type(username);
            pause(1000);
            flp.passwordinput.clear();
            flp.passwordinput.type(password);
            pause(1500);
            flp.loginbutton.click();
            waitForElementExist(flp.usernameLnk);
            waitForElementDisplayed(flp.usernameLnk);
            log.info("===end frontlogin Operation===");
        }
    }
}
